<template>
    <el-form :model="formData" @submit.prevent="submitForm" class="form-section">
      <div class="form-container">
        <div class="double-container">
          <div class="inputs-container">
            <el-form-item :label="startPointLabel" prop="startPoint">
              <el-select v-model="formData.startPoint" placeholder="请选择" class="select-right">
                <el-option
                  v-for="option in startPointOptions"
                  :key="option"
                  :label="option"
                  :value="option"
                ></el-option>
              </el-select>
            </el-form-item>
  
            <el-form-item :label="flightHeightLabel" prop="flightHeight">
              <el-select v-model="formData.flightHeight" placeholder="请选择" class="select-right">
                <el-option
                  v-for="option in flightHeightOptions"
                  :key="option"
                  :label="option"
                  :value="option"
                ></el-option>
              </el-select>
            </el-form-item>
  
            <el-form-item :label="safetyTypehLabel" prop="safetyTypeh">
              <el-input v-model="formData.safetyTypeh" placeholder="输入横向值" class="select-right"></el-input>
            </el-form-item>
  
            <el-form-item :label="safetyTypezLabel" prop="safetyTypez">
              <el-input v-model="formData.safetyTypez" placeholder="输入纵向值" class="select-right"></el-input>
            </el-form-item>
  
            <el-form-item :label="safetyTypecLabel" prop="safetyTypec">
              <el-input v-model="formData.safetyTypec" placeholder="输入垂直向值" class="select-right"></el-input>
            </el-form-item>
  
            <el-form-item :label="accLabel" prop="acc">
              <el-select v-model="formData.acc" placeholder="请选择" class="select-right">
                <el-option
                  v-for="option in accOptions"
                  :key="option"
                  :label="option"
                  :value="option"
                ></el-option>
              </el-select>
            </el-form-item>
  
            <el-form-item v-if="showNewInput" :label="extraInputLabel" prop="extraInput">
              <el-input v-model="formData.extraInput" placeholder="输入值" class="select-right"></el-input>
              <span class="inline-label">架\每小时</span>
            </el-form-item>
          </div>
  
          <div class="image-display">
            <img src="@/assets/img/left_top_lan.png" class="inputimage" />
          </div>
        </div>
  
        <div class="form-item1">
            <button type="submit" class="button1">确认</button>
            <button type="button" @click="resetForm" class="button1">重置</button>
        </div>
      </div>
    </el-form>
  </template>
  
  <script>
  export default {
    name: 'FormComponent',
    props: {
      formData: {
        type: Object,
        required: true,
      },
      startPointOptions: {
        type: Array,
        required: true
      },
      flightHeightOptions: {
        type: Array,
        required: true
      },
      accOptions: {
        type: Array,
        required: true
      },
      startPointLabel: {
        type: String,
        default: '航路类型'
      },
      flightHeightLabel: {
        type: String,
        default: '可用飞行高度'
      },
      safetyTypehLabel: {
        type: String,
        default: '安全间隔横向值'
      },
      safetyTypezLabel: {
        type: String,
        default: '安全间隔纵向值'
      },
      safetyTypecLabel: {
        type: String,
        default: '安全间垂直向值'
      },
      accLabel: {
        type: String,
        default: '导航精度误差'
      },
      showNewInput: {
        type: Boolean,
        default: false
      },
      extraInputLabel: {
        type: String,
        default: '监视容量'
      }
    },
    methods: {
      submitForm() {
        this.$emit('submit');
      },
      resetForm() {
        this.$emit('reset');
      }
    }
  }
  </script>
  
  <style scoped>
  .form-section {
    width: 100%;
    height: 100%;
  }
  
  .form-container {
    width: 99%;
    height: 100%;
    gap: 3%;
    border: 2px solid #007bff;
    padding: 2%;
    border-radius: 8px;
    flex-direction: column;
    position: relative;
  }
  
  .double-container {
    display: flex;
    gap: 3%;
    height: 80%;
    width: 100%;
  }
  
  .inputs-container {
    display: flex;
    flex-direction: column;
    margin-top: 2%;
    width: 45%;
    height: 100%;
  }
  
  .form-item1 {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    bottom: 40px;
    font-size: 16px;
    color: #ffffff;
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
  }

  .select-right {
   /* 统一设置输入框和选择框的宽度 */
  height: 10%; /* 统一设置输入框和选择框的高度 */
  width: 46%;  
  padding: 3.3%; /* 设置内边距 */
  background-color: transparent; /* 背景色与环境一致 */
  color: #ffffff;  
}

.select-right option {
  background-color: rgb(32, 39, 61); /* 设置下拉选项的背景颜色 */
  color: white;
  opacity: 0.5; 
}

  
  .image-display {
    display: flex;
    margin-top: 3%;
    width: 55%;
    height: 70%;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
  }
  
  .inputimage {
    width: 100%;
    height: 100%;
  }

  .button1 {
    background-color: #007bff;
    color: #ffffff;
    border: none;
    padding: 10px 30px;
    cursor: pointer;
    margin-right: 20px;
    margin-left: 20px;
    font-size: 20px;
    transition: background-color 0.3s, transform 0.3s;
  }
  .button1:hover {
    background-color: #0056b3;
    transform: scale(1.05);
  }
  .button1:active {
    background-color: #037df8;
  }
  </style>
  